<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <link rel="stylesheet" href="./CSS/all.css">
    <title>delivery</title>
</head>

<body>
    <div class="container">
        <div class="header">
            <h1>查询快递</h1>
        </div>
        <div class="searchNumber">
            <input type="text" placeholder="输入快递单号">
        </div>
        <div class="search">
            <select class="selectMethod">
                <option checked>选择你的请求方式</option>
                <option value="axios">axios</option>
                <option value="jq">ajax</option>
                <option value="js">原生ajax</option>
            </select>
        </div>
       <div class="list">

       </div>
    </div>

</body>
<style>
    .one:empty{
        display: none;
    }
    .input {
        outline: none;
    }

    .one {
        text-align: center;
        width: 95%;
        height: 70px;
        margin: 0 auto;
        padding-left: 20px;
        flex-wrap: wrap;
        color: black;
        border-radius: 10px;
        margin: 10px;
        font-size: 10px;
    }

    .searchNumber {
        width: 100%;
        height: 100px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .list{
        width: 100%;
        height: auot;
    }
</style>
<script type="module">
    import * as method from './JS/everyMethod.js'
    $(document).ready(function () {
        $('select').change(function (event) {
            let value = event.target.value
            let inputValue = $('input')[0].value
            const url = `http://express3.market.alicloudapi.com/express3?number=${inputValue}`
            if (value == 'jq') {
                method.xmlFindJq('GET', url, jqXhrGetData)
            } else if (value == 'axios') {
                method.axiosFind('GET', url, axiosGetData)
            } else if (value == 'js') {
                method.xmlFindJs('GET', url, jsXhrGetData)
            }
        })
        function axiosGetData(response) {

            execudateData(response.data)


        }
        function jqXhrGetData(response) {

            execudateData(response)

        }
        function jsXhrGetData(response) {
            execudateData(JSON.parse(response))

        }

        function execudateData(currentResponse) {

            const responseDataCurrent = currentResponse.data.info[0].logisticsTraceDetailList
            var strList;
            for (var i = 0; i < responseDataCurrent.length; i++) {
                var city = responseDataCurrent[i].areaName
                var createBox = `        <div class="card">
            <div class="one">
                <p><span>[${city}]</span><span>${responseDataCurrent[i].desc}</span></p>
                <p>2022-09-08 20:37:28</p>
            </div>
             </div>`
                strList += createBox
            }
            $('.list').append(strList)
        }
    })
</script>

</html>